package com.springboot.cloud.demos.ribbon.rest;

import com.springboot.cloud.common.core.entity.vo.Result;
import com.springboot.cloud.demos.entity.form.MomentCommentForm;
import com.springboot.cloud.demos.ribbon.service.MomentCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class MomentCommentController {

    @Autowired
    private MomentCommentService momentCommentService;


    @PostMapping("/momentComment")
    public Result add(@RequestBody MomentCommentForm momentCommentForm) {
        return momentCommentService.save(momentCommentForm);
    }

    @GetMapping("/momentComment/query")
    public Result query(@RequestParam(value = "momentId") String momentId, @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
        return momentCommentService.queryMomentComment(momentId, pageNo, pageSize);
    }

    @GetMapping("/momentComment/queryCount")
    public Result queryCount(@RequestParam(value = "momentId") String momentId) {
        return momentCommentService.queryCount(momentId);
    }
}
